package com.neu.utils;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 17478
 * @ClassName: BusinessException
 * @description: TODO
 * @date 2024-11-15 19:36
 * @version: 1.0
 */
public class BusinessException extends RuntimeException {

    private final ErrorCode errorCode;

    // 构造方法，使用错误码
    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    // 构造方法，支持自定义消息
    public BusinessException(ErrorCode errorCode, String customMessage) {
        super(customMessage);
        this.errorCode = errorCode;
    }

    public int getCode() {
        return errorCode.getCode();
    }

    public String getMessage() {
        return errorCode.getMessage();
    }
}

